package com.example.huixue.entity;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;

public class Resource {
    private Long resourceId;
    
    @NotBlank(message = "资源标题不能为空")
    @Size(max = 255, message = "资源标题长度不能超过255字符")
    private String title;
    
    private String description;
    private String filePath;
    private Long fileSize;
    private String fileType;
    private Integer downloadCount;
    private Integer viewCount;
    private Double rating;
    private Long categoryId;
    private Long uploaderId;
    private String status;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    
    // 关联属性
    private String username;
    private String categoryName;
    
    // 前端期望的字段别名
    public String getUploaderName() {
        return this.username;
    }
    
    public void setUploaderName(String uploaderName) {
        this.username = uploaderName;
    }
    
    public String getUploadTime() {
        return this.createdAt != null ? this.createdAt.toString() : null;
    }
    
    public Resource() {
        this.downloadCount = 0;
        this.viewCount = 0;
        this.rating = 0.0;
        this.status = "PENDING";
        this.createdAt = LocalDateTime.now();
    }
    
    // Getter和Setter方法
    public Long getResourceId() {
        return resourceId;
    }
    
    public void setResourceId(Long resourceId) {
        this.resourceId = resourceId;
    }
    
    public String getTitle() {
        return title;
    }
    
    public void setTitle(String title) {
        this.title = title;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public String getFilePath() {
        return filePath;
    }
    
    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }
    
    public Long getFileSize() {
        return fileSize;
    }
    
    public void setFileSize(Long fileSize) {
        this.fileSize = fileSize;
    }
    
    public String getFileType() {
        return fileType;
    }
    
    public void setFileType(String fileType) {
        this.fileType = fileType;
    }
    
    public Integer getDownloadCount() {
        return downloadCount;
    }
    
    public void setDownloadCount(Integer downloadCount) {
        this.downloadCount = downloadCount;
    }
    
    public Integer getViewCount() {
        return viewCount;
    }
    
    public void setViewCount(Integer viewCount) {
        this.viewCount = viewCount;
    }
    
    public Double getRating() {
        return rating;
    }
    
    public void setRating(Double rating) {
        this.rating = rating;
    }
    
    public Long getCategoryId() {
        return categoryId;
    }
    
    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }
    
    public Long getUploaderId() {
        return uploaderId;
    }
    
    public void setUploaderId(Long uploaderId) {
        this.uploaderId = uploaderId;
    }
    
    public String getStatus() {
        return status;
    }
    
    public void setStatus(String status) {
        this.status = status;
    }
    
    public LocalDateTime getCreatedAt() {
        return createdAt;
    }
    
    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }
    
    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }
    
    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }
    
    public String getUsername() {
        return username;
    }
    
    public void setUsername(String username) {
        this.username = username;
    }
    
    public String getCategoryName() {
        return categoryName;
    }
    
    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }
    
    @Override
    public String toString() {
        return "Resource{" +
                "resourceId=" + resourceId +
                ", title='" + title + '\'' +
                ", description='" + description + '\'' +
                ", filePath='" + filePath + '\'' +
                ", fileSize=" + fileSize +
                ", fileType='" + fileType + '\'' +
                ", downloadCount=" + downloadCount +
                ", viewCount=" + viewCount +
                ", rating=" + rating +
                ", categoryId=" + categoryId +
                ", uploaderId=" + uploaderId +
                ", status='" + status + '\'' +
                ", createdAt=" + createdAt +
                ", updatedAt=" + updatedAt +
                ", username='" + username + '\'' +
                ", categoryName='" + categoryName + '\'' +
                '}';
    }
} 